home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Help! How do I reset a ifstream file-pointer to beginning?
- Date: Tue, 06 Feb 1996 14:01:27 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <31175127.167EB0E7@intellektik.informatik.th-darmstadt.de>
- References: <311734E8.41C6@dlr.de>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (X11; I; SunOS 4.1.3 sun4m)
-
- Matthias Sodomann wrote:
- >
- > Hi there,
- >
- > I have a question concerning ifstream operation. I like to read a file.
- > It is ASCII. I got me an ifstream in; and opened the file with
- > in.open("filename",ios::in); So far so good. I read the whole file, and
- > after this I have to read it again. The reason doesn't matter! How do I
- > reset the file to start reading from the beginning WITHOUT closing and
- > reopening it? I tried to use in.seekg(0); or in.seekg(0,ios:beg); but
- > all this didn't help. What do I have to do? Or is this maybe a matter of
- > compiler? I work on a IBM RS600 AIX3.2 Workstation with the IBM C++
- > Compiler xlC.
- >
-
- You have to reset the stream-state with the 'clear' member function,
- e.g. add a line 'in.clear();' before you call 'in.seekg(0)'.
-
- Enno
-